﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="toimiku_dokumendid_dokument", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(ToimikuDokumendidDokument))]
    public class ToimikuDokumendidDokumentSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IToimikuDokumendidDokument clazz;
        
        public ToimikuDokumendidDokumentSerializer(IToimikuDokumendidDokument clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("dokumendi_id");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.DokumendiId))).ToString());
            Writer.WriteEndElement();
            if (clazz.PohiDokumendiId!=null) {
                Writer.WriteStartElement("pohi_dokumendi_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.PohiDokumendiId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MenetluseNumber!=null) {
                Writer.WriteStartElement("menetluse_number");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MenetluseNumber))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MenetluseAlgusKuupaev!=null) {
                Writer.WriteStartElement("menetluse_algus_kuupaev");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.MenetluseAlgusKuupaev))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MenetluseLoppKuupaev!=null) {
                Writer.WriteStartElement("menetluse_lopp_kuupaev");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.MenetluseLoppKuupaev))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.DokumendiLiik!=null) {
                Writer.WriteStartElement("dokumendi_liik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokumendiLiik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.DokumendiLiikTekstina!=null) {
                Writer.WriteStartElement("dokumendi_liik_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokumendiLiikTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.DokumendiOlek!=null) {
                Writer.WriteStartElement("dokumendi_olek");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokumendiOlek))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.DokumendiOlekTekstina!=null) {
                Writer.WriteStartElement("dokumendi_olek_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokumendiOlekTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.NotariId!=null) {
                Writer.WriteStartElement("notari_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.NotariId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.NotariNimi!=null) {
                Writer.WriteStartElement("notari_nimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.NotariNimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.NotariIsikukood!=null) {
                Writer.WriteStartElement("notari_isikukood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.NotariIsikukood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.NotariTehinguNr!=null) {
                Writer.WriteStartElement("notari_tehingu_nr");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.NotariTehinguNr))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.NotariTehinguAasta!=null) {
                Writer.WriteStartElement("notari_tehingu_aasta");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.NotariTehinguAasta))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.DokumendiParitolu!=null) {
                Writer.WriteStartElement("dokumendi_paritolu");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokumendiParitolu))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.DokumendiParitoluTekstina!=null) {
                Writer.WriteStartElement("dokumendi_paritolu_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokumendiParitoluTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.DokumendiFailinimi!=null) {
                Writer.WriteStartElement("dokumendi_failinimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokumendiFailinimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.DokumendiSuurus!=null) {
                Writer.WriteStartElement("dokumendi_suurus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.DokumendiSuurus))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="dokumendi_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>toimiku_dokumendid_dokument>dokumendi_id");
                }
                clazz.DokumendiId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("dokumendi_id")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>toimiku_dokumendid_dokument>dokumendi_id", Reader.LocalName);
            }
            if (Reader.LocalName=="pohi_dokumendi_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>toimiku_dokumendid_dokument>pohi_dokumendi_id");
                }
                clazz.PohiDokumendiId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("pohi_dokumendi_id")).Value;
            }
            if (Reader.LocalName=="menetluse_number") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>toimiku_dokumendid_dokument>menetluse_number");
                }
                clazz.MenetluseNumber = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("menetluse_number")).Value;
            }
            if (Reader.LocalName=="menetluse_algus_kuupaev") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MenetluseAlgusKuupaev = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("menetluse_algus_kuupaev")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="menetluse_lopp_kuupaev") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MenetluseLoppKuupaev = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("menetluse_lopp_kuupaev")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="dokumendi_liik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.DokumendiLiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dokumendi_liik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="dokumendi_liik_tekstina") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.DokumendiLiikTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dokumendi_liik_tekstina")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="dokumendi_olek") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.DokumendiOlek = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dokumendi_olek")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="dokumendi_olek_tekstina") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.DokumendiOlekTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dokumendi_olek_tekstina")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="notari_id") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.NotariId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("notari_id")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="notari_nimi") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.NotariNimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("notari_nimi")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="notari_isikukood") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.NotariIsikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("notari_isikukood")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="notari_tehingu_nr") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.NotariTehinguNr = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("notari_tehingu_nr")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="notari_tehingu_aasta") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.NotariTehinguAasta = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("notari_tehingu_aasta")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="dokumendi_paritolu") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.DokumendiParitolu = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dokumendi_paritolu")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="dokumendi_paritolu_tekstina") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.DokumendiParitoluTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dokumendi_paritolu_tekstina")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="dokumendi_failinimi") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.DokumendiFailinimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dokumendi_failinimi")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="dokumendi_suurus") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.DokumendiSuurus = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("dokumendi_suurus")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
        }
    }
}
